package com.abyss.source;


import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 从文件中读取数据
 */
public class FileSourceDemo {
    public static void main(String[] args) throws Exception {
        // 1. env
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        // 2.1 从local file中读取
        DataStreamSource<String> localFileSource = env.readTextFile("/Users/abyss/Dev/toys/flink/H-flink-learn/src/main/resources/score.csv").setParallelism(6);

        // 2.2 从hdfs file中读取
        DataStreamSource<String> hdfsSource = env.readTextFile("hdfs://node1:8000/test/people.txt");

        // 3. 输出
        localFileSource.print();
        hdfsSource.print();

        // 4. 提交
        env.execute();
    }
}